home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / comm / term / term34Source.lha / termData.c < prev    next >
C/C++ Source or Header  |  1993-07-16  |  22KB  |  876 lines

  1. /*
  2. **    termData.c
  3. **
  4. **    Global data structures.
  5. **
  6. **    Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12.     /* Libraries. */
  13.  
  14. struct ExecBase        *SysBase;
  15. struct DosLibrary    *DOSBase;
  16.  
  17. struct IntuitionBase    *IntuitionBase;
  18. struct GfxBase        *GfxBase;
  19. struct RxsLib        *RexxSysBase;
  20. struct LocaleBase    *LocaleBase;
  21. struct Library        *GadToolsBase,
  22.             *TimerBase,
  23.             *ConsoleDevice,
  24.             *DiskfontBase,
  25.             *UtilityBase,
  26.             *AslBase,
  27.             *IFFParseBase,
  28.             *CxBase,
  29.             *IconBase,
  30.             *LayersBase,
  31.             *TranslatorBase,
  32.             *WorkbenchBase,
  33.             *AmigaGuideBase,
  34.             *XEmulatorBase,
  35.             *XProtocolBase,
  36.             *OwnDevUnitBase;
  37.  
  38. BYTE             Kick30;
  39.  
  40.     /* Timer device. */
  41.  
  42. struct timerequest    *TimeRequest;
  43. struct MsgPort        *TimePort;
  44.  
  45.     /* Console device. */
  46.  
  47. struct IOStdReq        *ConsoleRequest;
  48. struct KeyMap        *KeyMap;
  49. BPTR             KeySegment;
  50.  
  51.     /* Screen & Windows. */
  52.  
  53. struct Screen        *Screen,
  54.             *DefaultPubScreen;
  55. struct Window        *Window;
  56. LONG             WindowWidth,
  57.              WindowHeight,
  58.              WindowLeft,
  59.              WindowTop;
  60. struct Window        *StatusWindow;
  61. struct Gadget        *StatusGadget;
  62. UWORD             StatusOffset;
  63. APTR             OldWindowPtr;
  64. struct BitMap        *InterleavedBitMap;
  65. struct Requester    *RequesterList;
  66. UBYTE             ScreenTitle[80];
  67. UBYTE             DepthMask;
  68. LONG             RenderPens[4],
  69.              MappedPens[2][32],
  70.              SafeTextPen;
  71. struct DrawInfo        *DrawInfo;
  72. LONG             ScreenWidth,
  73.              ScreenHeight;
  74. BYTE             UseMasking;
  75.  
  76. struct BlockMarker    *WindowMarker;
  77. ULONG             ClickSecs,ClickMicros;
  78. BYTE             FirstClick = TRUE,HoldClick = FALSE;
  79. LONG             ClickX,ClickY;
  80.  
  81.     /* Workbench AppWindow support. */
  82.  
  83. struct AppWindow    *WorkbenchWindow;
  84. struct MsgPort        *WorkbenchPort;
  85.  
  86.     /* Graphics rendering. */
  87.  
  88. struct ViewPort        *VPort;
  89. struct RastPort        *RPort;
  90. struct Region        *ClipRegion,
  91.             *OldRegion;
  92. struct TextFont        *GFX,
  93.             *CurrentFont,
  94.             *UserTextFont;
  95. WORD             UserFontHeight,
  96.              UserFontWidth,
  97.              UserFontBase;
  98. UBYTE             UserFontName[40];
  99. struct TextFont        *TextFont;
  100. WORD             TextFontHeight,
  101.              TextFontWidth,
  102.              TextFontBase;
  103. struct TTextAttr     TextAttr;
  104. UBYTE             TextFontName[40];
  105. struct TTextAttr     UserFont;
  106. struct TagItem         TagDPI[2];
  107. APTR             VisualInfo;
  108. UWORD             FontRightExtend;
  109.  
  110. ULONG            (* __regargs ReadAPen)(struct RastPort *RPort);
  111. ULONG            (* __regargs ReadBPen)(struct RastPort *RPort);
  112. ULONG            (* __regargs ReadDrMd)(struct RastPort *RPort);
  113. ULONG            (* __regargs SetWrMsk)(struct RastPort *RPort,ULONG Mask);
  114.  
  115. UWORD StandardPens[] =
  116. {
  117.     0,1,1,2,1,3,1,0,2,    1,2,1,(UWORD)~0
  118. };
  119.  
  120. UWORD ANSIPens[] =
  121. {
  122.     0,4,7,7,4,6,7,0,6,    0,7,0,(UWORD)~0
  123. };
  124.  
  125. UWORD EGAPens[] =
  126. {
  127.     0,15,15,15,8,7,15,0,7,    0,15,0,(UWORD)~0
  128. };
  129.  
  130. UWORD AtomicColours[16] =
  131. {
  132.     0x000,
  133.     0xDDD,
  134.     0x000,
  135.     0x000,
  136.     0x000,
  137.     0x000,
  138.     0x000,
  139.     0x000,
  140.     0x000,
  141.     0x000,
  142.     0x000,
  143.     0x000,
  144.     0x000,
  145.     0x000,
  146.     0x000,
  147.     0x000
  148. };
  149.  
  150. UWORD EGAColours[16] =
  151. {
  152.     0x000,    /* Black. */
  153.     0xA00,    /* Dark red. */
  154.     0x0A0,    /* Dark green. */
  155.     0xA60,    /* Dark yellow (orange). */
  156.     0x00A,    /* Dark blue. */
  157.     0xA0A,    /* Dark magenta.*/
  158.     0x0AA,    /* Dark cyan. */
  159.     0xBBB,    /* Light grey. */
  160.     0x666,    /* Dark grey. */
  161.     0xF00,    /* Red. */
  162.     0x0F0,    /* Green. */
  163.     0xFF0,    /* Yellow. */
  164.     0x00F,    /* Blue. */
  165.     0xF0F,    /* Magenta. */
  166.     0x0FF,    /* Cyan. */
  167.     0xFFF    /* White. */
  168. };
  169.  
  170. UWORD ANSIColours[16] =
  171. {
  172.     0x000,    /* Black. */
  173.     0xF00,    /* Red. */
  174.     0x0F0,    /* Green. */
  175.     0xFF0,    /* Yellow. */
  176.     0x00F,    /* Blue. */
  177.     0xF0F,    /* Magenta. */
  178.     0x0FF,    /* Cyan. */
  179.     0xFFF,    /* White. */
  180.  
  181.     0x000,    /* Black. */
  182.     0xF00,    /* Red. */
  183.     0x0F0,    /* Green. */
  184.     0xFF0,    /* Yellow. */
  185.     0x00F,    /* Blue. */
  186.     0xF0F,    /* Magenta. */
  187.     0x0FF,    /* Cyan. */
  188.     0xFFF    /* White. */
  189. };
  190.  
  191. UWORD             DefaultColours[32],
  192.              BlinkColours[32],
  193.              NormalColours[32],
  194.              StandardColours[32],
  195.              PaletteSize = 16;
  196.  
  197.     /* Line/Column offset tables. */
  198.  
  199. LONG            *OffsetXTable,
  200.             *OffsetYTable;
  201.  
  202.     /* DOS data. */
  203.  
  204. struct Process        *ThisProcess;
  205. struct Process        *StatusProcess;
  206. struct Process        *BufferProcess;
  207. struct Process        *RexxProcess,
  208.             *RexxBackgroundProcess;
  209. struct MsgPort        *TermRexxPort;
  210. struct WBStartup    *WBenchMsg;
  211. BPTR             WBenchLock;
  212. struct TermPort        *TermPort;
  213. BYTE             ClipBit    = -1,
  214.              CheckBit    = -1;
  215. BYTE             InRexx;
  216. WORD             LimitCount    = -1;
  217. UBYTE             LimitMacro[MAX_FILENAME_LENGTH];
  218.  
  219.     /* Character conversion. */
  220.  
  221. struct InputEvent    *FakeInputEvent;
  222.  
  223.     /* Serial I/O. */
  224.  
  225. struct IOExtSer        *ReadRequest;
  226. struct IOExtSer        *WriteRequest;
  227. struct MsgPort        *ReadPort;
  228. APTR             ReadBuffer,
  229.              HostReadBuffer;
  230. UBYTE            *SerialMessage;
  231. ULONG             DTERate;
  232.  
  233. UBYTE             NewDevice[MAX_FILENAME_LENGTH];
  234. LONG             NewUnit;
  235. BYTE             UseNewDevice,
  236.              UseNewUnit;
  237.  
  238. LONG BaudRates[] =
  239. {
  240.     110,300,600,1200,2400,4800,7200,9600,12000,14400,19200,31250,38400,57600,64000,76800,115200
  241. };
  242.  
  243. LONG             NumBaudRates = sizeof(BaudRates) / sizeof(LONG);
  244.  
  245.     /* Localization support. */
  246.  
  247. struct Catalog        *Catalog;
  248. struct Locale        *Locale;
  249.  
  250.     /* Hotkeys. */
  251.  
  252. struct Hotkeys         Hotkeys;
  253.  
  254. struct NewBroker NewTermBroker =
  255. {
  256.     NB_VERSION,
  257.     "term",
  258.     "term © 1990-1993 by MXM",
  259.     "Terminal program",
  260.     0,0,0,NULL,0
  261. };
  262.  
  263.     /* Static default fonts. */
  264.  
  265. struct TextAttr DefaultFont =
  266. {
  267.     (UBYTE *)"topaz.font",
  268.     8,
  269.     FS_NORMAL,
  270.     FPF_ROMFONT | FPF_DESIGNED
  271. };
  272.  
  273. struct TextAttr GFXFont =
  274. {
  275.     (UBYTE *)"GFX.font",
  276.     8,
  277.     FS_NORMAL,
  278.     FPF_DISKFONT
  279. };
  280.  
  281.     /* Character lookup tables. */
  282.  
  283. BYTE IsPrintable[256] =
  284. {
  285.     0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,
  286.     0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,
  287.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  288.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  289.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  290.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  291.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  292.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
  293.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  294.     0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,
  295.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  296.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  297.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  298.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  299.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  300.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  301. };
  302.  
  303. BYTE CharType[256] =
  304. {
  305.     0,0,0,0,0,0,0,0,0,0,6,0,0,7,0,0,
  306.     0,5,0,4,0,0,0,0,0,0,0,0,0,0,0,0,
  307.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  308.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  309.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  310.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  311.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  312.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  313.     2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,
  314.     0,0,0,0,0,3,1,1,1,1,0,0,0,0,0,0,
  315.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  316.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  317.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  318.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  319.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  320.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  321. };
  322.  
  323.     /* IBM <-> ISO font conversion. */
  324.  
  325. UBYTE IBMConversion[256] =
  326. {
  327.     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x00,0x00,
  328.     0x00,0x11,0x00,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1B,0x00,0x00,0x00,0x00,
  329.     0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
  330.     0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
  331.     0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
  332.     0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
  333.     0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
  334.     0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
  335.     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  336.     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  337.     0x00,0xAD,0x9B,0x9C,0x00,0x9D,0x00,0x15,0x00,0x00,0xA6,0x00,0x00,0x00,0xAE,0x00,
  338.     0xF8,0xF1,0xFD,0x00,0x00,0xE6,0x14,0xF9,0x00,0x00,0xA7,0xAF,0xAC,0xAB,0x00,0xA8,
  339.     0x00,0x00,0x00,0x00,0x8E,0x8F,0x92,0x80,0x00,0x90,0x00,0x00,0x00,0x00,0x00,0x00,
  340.     0x00,0xA5,0x00,0x00,0x00,0x00,0x99,0x00,0x00,0x00,0x00,0x00,0x9A,0x00,0x00,0xE1,
  341.     0x85,0xA0,0x83,0x00,0x84,0x86,0x91,0x87,0x8A,0x82,0x88,0x89,0x8D,0xA1,0x8C,0x00,
  342.     0x00,0xA4,0x95,0xA2,0x93,0x00,0x94,0x00,0x00,0x97,0xA3,0x96,0x81,0x00,0x00,0x98
  343. };
  344.  
  345.     /* Table of graphics characters. */
  346.  
  347. BYTE GfxTable[256] =
  348. {
  349.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  350.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  351.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  352.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  353.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  354.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  355.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  356.     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  357.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  358.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  359.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  360.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  361.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  362.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  363.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  364.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  365. };
  366.  
  367.     /* Special character treatment. */
  368.  
  369. struct SpecialKey SpecialKeys[13] =
  370. {
  371.     BEL,    DoBeep,        /* Ring the bell. */
  372.     XON,    DoxON,        /* Flow control - stop output. */
  373.     BKS,    DoBackspace,    /* Erase a character. */
  374.     ENT,    DoLF_FF_VT,    /* Enter key. */
  375.     FFD,    DoFF,        /* Form feed. */
  376.     VTB,    DoLF_FF_VT,    /* Vertical tab (huh?). */
  377.     RET,    DoCR,        /* Return key. */
  378.     TAB,    DoTab,        /* Move to next tab stop. */
  379.     SI,    DoShiftIn,    /* Change to graphics mode */
  380.     SO,    DoShiftOut,    /* Change out of graphics mode. */
  381.     ENQ,    DoEnq,        /* Transmit answerback message. */
  382.     ESC,    DoEsc,        /* Start new control sequence. */
  383.     CSI,    DoCsi        /* Start new control sequence. */
  384. };
  385.  
  386. JUMP *SpecialTable;
  387.  
  388. BYTE AbortMap[256] =
  389. {
  390.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  391.     0,0,0,0,0,0,0,0,1,0,1,2,0,0,0,0,
  392.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  393.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  394.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  395.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  396.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  397.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  398.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  399.     0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,
  400.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  401.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  402.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  403.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  404.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  405.     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  406. };
  407.  
  408. JUMP *AbortTable;
  409.  
  410. VOID (* __regargs ConDump)(STRPTR,LONG);
  411. VOID (* __regargs ConOutput)(STRPTR,LONG);
  412. VOID (* __regargs ConProcessData)(register STRPTR,register LONG);
  413.  
  414.     /* Shared global string formatting buffer. */
  415.  
  416. UBYTE SharedBuffer[512];
  417.  
  418.     /* Some more handy buffers. */
  419.  
  420. UBYTE ARexxCommandBuffer[256],AmigaDOSCommandBuffer[256];
  421.  
  422.     /* Screen pull-down-menu. */
  423.  
  424. struct NewMenu TermMenu[] =
  425. {
  426.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  427.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)0},
  428.     {   NM_SUB, NULL,         0 , 0,        0, (APTR)MEN_SAVE_AS_PICTURE},
  429.     {   NM_SUB, NULL,         0 , 0,        0, (APTR)MEN_SAVE_AS_TEXT},
  430.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  431.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)0},
  432.     {   NM_SUB, NULL,         0 , 0,        0, (APTR)MEN_PRINT_SCREEN},
  433.     {   NM_SUB, NULL,         0 , 0,        0, (APTR)MEN_PRINT_CLIP},
  434.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  435.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)0},
  436.     {   NM_SUB, NULL,         0 , TICK,    0, (APTR)MEN_CAPTURE_TO_FILE},
  437.     {   NM_SUB, NULL,         0 , TICK,    0, (APTR)MEN_CAPTURE_TO_PRINTER},
  438.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  439.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_ICONIFY},
  440.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  441.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_ABOUT},
  442.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  443.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_QUIT},
  444.  
  445.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  446.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_COPY},
  447.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_PASTE},
  448.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CLEAR},
  449.  
  450.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  451.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_EXECUTE_DOS_COMMAND},
  452.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_EXECUTE_REXX_COMMAND},
  453.  
  454.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  455.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_PHONEBOOK},
  456.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_REDIAL},
  457.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_DIAL_NUMBER},
  458.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  459.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SEND_BREAK},
  460.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_HANG_UP},
  461.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  462.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_WAIT},
  463.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  464.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_FLUSH_BUFFER},
  465.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_RELEASE_DEVICE},
  466.  
  467.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  468.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_UPLOAD_ASCII},
  469.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_DOWNLOAD_ASCII},
  470.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  471.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_UPLOAD_TEXT},
  472.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_DOWNLOAD_TEXT},
  473.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_EDIT_AND_UPLOAD_TEXT},
  474.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  475.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_UPLOAD_BINARY},
  476.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_DOWNLOAD_BINARY},
  477.  
  478.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  479.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CLEAR_BUFFER},
  480.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_DISPLAY_BUFFER},
  481.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CLOSE_BUFFER},
  482.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  483.     {  NM_ITEM, NULL,         0 , TICK,    0, (APTR)MEN_FREEZE_BUFFER},
  484.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  485.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_OPEN_BUFFER},
  486.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SAVE_BUFFER_AS},
  487.  
  488.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  489.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CLEAR_SCREEN},
  490.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_RESET_FONT},
  491.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_RESET_STYLES},
  492.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_RESET_TERMINAL},
  493.  
  494.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  495.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SERIAL},
  496.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_MODEM},
  497.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SCREEN},
  498.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_TERMINAL},
  499.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SET_EMULATION},
  500.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CLIPBOARD},
  501.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CAPTURE},
  502.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_COMMANDS},
  503.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_MISC},
  504.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_PATH},
  505.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_TRANSFER_PROTOCOL},
  506.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  507.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_TRANSFER},
  508.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_TRANSLATION},
  509.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_MACROS},
  510.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_CURSORKEYS},
  511.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_FAST_MACROS},
  512.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_HOTKEYS},
  513.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SPEECH},
  514.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SOUND},
  515.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SET_CONSOLE},
  516.     {  NM_ITEM, NM_BARLABEL,     0 , 0,        0, (APTR)0},
  517.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_OPEN_SETTINGS},
  518.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SAVE_SETTINGS},
  519.     {  NM_ITEM, NULL,         0 , 0,        0, (APTR)MEN_SAVE_SETTINGS_AS},
  520.  
  521.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  522.     {  NM_ITEM, NULL,         0 , TICK,    0, (APTR)MEN_STATUS_WINDOW},
  523.     {  NM_ITEM, NULL,         0 , TICK,    0, (APTR)MEN_REVIEW_WINDOW},
  524.     {  NM_ITEM, NULL,         0 , CHECKIT,    0, (APTR)MEN_PACKET_WINDOW},
  525.     {  NM_ITEM, NULL,         0 , TICK,    0, (APTR)MEN_FAST_MACROS_WINDOW},
  526.  
  527.     { NM_TITLE, NULL,         0 , 0,        0, (APTR)0},
  528.     {   NM_END, 0,             0 , 0,        0, (APTR)0}
  529. };
  530.  
  531. struct Menu *Menu;
  532.  
  533.     /* Pointer. */
  534.  
  535. UWORD __chip Stopwatch[(1 + 16 + 1) * 2] =
  536. {
  537.     0x0000,0x0000,
  538.  
  539.     0x0400,0x07C0,
  540.     0x0000,0x07C0,
  541.     0x0100,0x0380,
  542.     0x0000,0x07E0,
  543.     0x07C0,0x1FF8,
  544.     0x1FF0,0x3FEC,
  545.     0x3FF8,0x7FDE,
  546.     0x3FF8,0x7FBE,
  547.     0x7FFC,0xFF7F,
  548.     0x7EFC,0xFFFF,
  549.     0x7FFC,0xFFFF,
  550.     0x3FF8,0x7FFE,
  551.     0x3FF8,0x7FFE,
  552.     0x1FF0,0x3FFC,
  553.     0x07C0,0x1FF8,
  554.     0x0000,0x07E0,
  555.  
  556.     0x0000,0x0000
  557. };
  558.  
  559.     /* Cross-hatch pattern. */
  560.  
  561. ULONG __chip Crosshatch = 0x5555AAAA;
  562.  
  563.     /* Ghosting pattern, slightly different from the cross-hatch pattern. */
  564.  
  565. ULONG __chip Ghosting = 0x44441111;
  566.  
  567.     /* Configuration. */
  568.  
  569. struct Configuration    *Config,
  570.             *PrivateConfig,
  571.             *BackupConfig;
  572. struct SpeechConfig     SpeechConfig;
  573. BYTE             English = TRUE;
  574. BYTE             Status;
  575. BYTE             Online,WasOnline;
  576. ULONG             OnlineMinutes,OnlinePlus;
  577. UWORD             PublicModes;
  578.  
  579. UBYTE             LastConfig[MAX_FILENAME_LENGTH];
  580. UBYTE             DefaultPubScreenName[MAXPUBSCREENNAME + 1],
  581.              SomePubScreenName[MAXPUBSCREENNAME + 1];
  582.  
  583.     /* Capture file. */
  584.  
  585. struct Buffer        *FileCapture;
  586. BPTR             PrinterCapture;
  587. UBYTE             CaptureName[MAX_FILENAME_LENGTH];
  588. BYTE             StandardPrinterCapture,
  589.              ControllerActive;
  590. LONG             BufferFlushCount;
  591.  
  592.     /* Buffer. */
  593.  
  594. UBYTE            **BufferLines;
  595. LONG             Lines;
  596. struct SignalSemaphore    *BufferSemaphore;
  597. LONG             MaxLines = 100;
  598. LONG             BufferSpace;
  599. BYTE             BufferClosed;
  600. BYTE             BufferFrozen;
  601.  
  602.     /* Sound support.c */
  603.  
  604. struct SoundConfig     SoundConfig;
  605. BYTE             SoundChanged = FALSE;
  606.  
  607.     /* Phonebook. */
  608.  
  609. struct PhoneEntry    **Phonebook;
  610. LONG             PhoneSize;
  611. LONG             NumPhoneEntries;
  612. UBYTE             PhonePassword[256];
  613. BYTE             PhonePasswordUsed,
  614.              RebuildMenu;
  615. UBYTE             Password[100];
  616. UBYTE             UserName[100];
  617. UBYTE             GlobalPassword[256];
  618.  
  619. UBYTE             CurrentBBSName[40],
  620.              CurrentBBSNumber[100],
  621.              CurrentBBSComment[100];
  622.  
  623. UBYTE             LastPhone[MAX_FILENAME_LENGTH];
  624. UBYTE             LastKeys[MAX_FILENAME_LENGTH];
  625. UBYTE             LastMacros[MAX_FILENAME_LENGTH];
  626. UBYTE             LastCursorKeys[MAX_FILENAME_LENGTH];
  627. UBYTE             LastTranslation[MAX_FILENAME_LENGTH];
  628. UBYTE             LastSpeech[MAX_FILENAME_LENGTH];
  629. UBYTE             LastSound[MAX_FILENAME_LENGTH];
  630.  
  631. struct MacroKeys    *MacroKeys;
  632. struct CursorKeys    *CursorKeys;
  633.  
  634.     /* Console stuff. */
  635.  
  636. UBYTE            *StripBuffer;
  637. UWORD             LastLine,LastColumn,LastPixel;
  638. BYTE             Charset,Attributes,FgPen,BgPen;
  639. WORD             CursorX,CursorY,Top,Bottom;
  640. BYTE             UseRegion,RegionSet,InSequence,Quiet,Blocking;
  641. BYTE            *TabStops;
  642. UWORD             TabStopMax;
  643. BYTE             CharMode[2];
  644.  
  645. BYTE             ResetDisplay,
  646.              DisplayReopened,
  647.              FixPubScreenMode,
  648.              FixScreenSize,
  649.              Apocalypse;
  650.  
  651.     /* Flow filter. */
  652.  
  653. STRPTR             AttentionBuffers[SCAN_COUNT];
  654. BYTE             BaudPending,FullCheck,UseFlow;
  655. UBYTE             BaudBuffer[80],BaudCount;
  656.  
  657. struct FlowInfo         FlowInfo;
  658.  
  659. STRPTR             DataHold;
  660. LONG             DataSize;
  661.  
  662.     /* Transfer data. */
  663.  
  664. BYTE             BinaryTransfer;
  665. LONG             TransferBits;
  666.  
  667. VOID            (* __regargs ConTransfer)(STRPTR,LONG);
  668.  
  669. UBYTE            *DownloadPath;
  670. BYTE             Uploading;
  671. BYTE             DidTransfer;
  672.  
  673. struct Window        *TransferWindow,
  674.             *TransferPerfWindow;
  675. struct Menu        *TransferMenu;
  676. struct Gadget        *TransferGadgetArray[GAD_TRANSFER_SKIP + 1];
  677. struct List         TransferInfoList;
  678. struct TextBox        *TransferBoxArray[BOX_TRANSFER_RIGHT2 + 1],
  679.             *TransferBoxList;
  680. struct List         TransferInfoList;
  681.  
  682. struct FileTransferInfo    *FileTransferInfo;
  683.  
  684. struct XPR_IO        *XprIO;
  685.  
  686. UBYTE             ProtocolOptsBuffer[256];
  687. BYTE             NewLibrary,NewOptions;
  688. UBYTE             LastXprLibrary[MAX_FILENAME_LENGTH];
  689. UBYTE             ConvNumber[30],ConvNumber10[30];
  690. BYTE             UsesZModem,SendAbort,TransferAborted,TransferFailed,TransferError;
  691.  
  692.     /* The standard ZModem cancel sequence
  693.      * (ten CAN chars followed by ten
  694.      * BS chars).
  695.      */
  696.  
  697. UBYTE ZModemCancel[] =
  698. {
  699.     24,24,24,24,24,24,24,24,24,24,8,8,8,8,8,8,8,8,8,8
  700. };
  701.  
  702.     /* Pay per minute. */
  703.  
  704. LONG             CurrentPay;
  705. LONG             PayPerUnit[2];
  706. LONG             SecPerUnit[2];
  707. LONG             WhichUnit;
  708. struct PhoneEntry    *ChosenEntry;
  709. BYTE             ChosenInUse;
  710.  
  711.     /* Execute a command/script. */
  712.  
  713. UBYTE             WindowName[256];
  714.  
  715. BYTE             WeAreBlocking;
  716.  
  717.     /* Dial list. */
  718.  
  719. struct List        *DialList;
  720.  
  721. BYTE             SendStartup;
  722.  
  723.     /* TermMain data. */
  724.  
  725. BYTE             ReleaseSerial;
  726. BYTE             ResetSerial;
  727. BYTE             MainTerminated,
  728.              IconTerminated = TRUE,
  729.              DoIconify = FALSE,
  730.              DoDial = DIAL_IGNORE;
  731.  
  732. BYTE             ConfigChanged,PhonebookChanged,TranslationChanged,
  733.              MacroChanged,CursorKeysChanged,FastMacrosChanged,
  734.              HotkeysChanged,SpeechChanged,BufferChanged;
  735.  
  736.     /* Upload/Download paths. */
  737.  
  738. UBYTE             LastDownload[MAX_FILENAME_LENGTH];
  739. UBYTE             LastUpload[MAX_FILENAME_LENGTH];
  740.  
  741.     /* String gadget hooks. */
  742.  
  743. struct Hook         CommandHook,
  744.              PasswordHook;
  745. BYTE             DontActivate;
  746.  
  747. struct Window        *CommandWindow;
  748. struct Gadget        *CommandGadget;
  749. struct Gadget        *ActiveGadget;
  750.  
  751. struct Process        *ClipProcess;
  752. struct MsgPort        *ClipPort;
  753. BYTE             ClipInput,
  754.              ClipXerox,
  755.              ClipPrefix;
  756.  
  757.     /* Text sending. */
  758.  
  759. UBYTE             SendPrompt[256];
  760. LONG             SendPromptLen;
  761. BYTE            (* __regargs SendLine)(register STRPTR,register LONG);
  762.  
  763.     /* Packet window. */
  764.  
  765. struct Window        *PacketWindow;
  766. struct Gadget        *PacketGadgetArray[2];
  767. struct Menu        *PacketMenu;
  768. struct Gadget        *PacketGadgetList;
  769. struct List         PacketHistoryList;
  770.  
  771.     /* Some more colour control flags. */
  772.  
  773. BYTE             Initializing,LoadColours;
  774.  
  775.     /* The character raster. */
  776.  
  777. UBYTE            *Raster,*RasterAttr;
  778. LONG             RasterWidth,RasterHeight;
  779. BYTE             Marking;
  780. struct SignalSemaphore    *RasterSemaphore;
  781. BYTE             RasterEnabled = TRUE;
  782.  
  783.     /* Generic lists. */
  784.  
  785. struct GenericList    *GenericListTable[GLIST_COUNT];
  786.  
  787.     /* File version test. */
  788.  
  789. ULONG VersionProps[2] =
  790. {
  791.     ID_TERM,
  792.     ID_VERS
  793. };
  794.  
  795.     /* Window stack. */
  796.  
  797. struct Window        *TopWindow;
  798.  
  799. struct Window        *WindowStack[5];
  800. WORD             WindowStackPtr;
  801.  
  802.     /* Global term ID. */
  803.  
  804. LONG             TermID;
  805. UBYTE             TermIDString[MAXPUBSCREENNAME + 1];
  806. UBYTE             RexxPortName[256];
  807.  
  808.     /* Fast! macros. */
  809.  
  810. struct List         FastMacroList;
  811. LONG             FastMacroCount;
  812. UBYTE             LastFastMacros[MAX_FILENAME_LENGTH];
  813. struct Window        *FastWindow;
  814. WORD             FastWindowLeft        = -1,
  815.              FastWindowTop        = -1,
  816.              FastWindowHeight    = -1;
  817.  
  818.     /* Double-buffered file locking. */
  819.  
  820. struct List         DoubleBufferList;
  821. struct SignalSemaphore     DoubleBufferSemaphore;
  822.  
  823.     /* XEM interface. */
  824.  
  825. struct XEM_IO        *XEM_IO;
  826. ULONG             XEM_Signal;
  827. struct XEmulatorHostData XEM_HostData;
  828. UBYTE            *OptionTitle;
  829. struct List         XEM_MacroList;
  830. struct XEmulatorMacroKey *XEM_MacroKeys;
  831. UBYTE             EmulationName[40];
  832.  
  833. struct List         EmptyList;
  834.  
  835.     /* Screen scrolling support. */
  836.  
  837. UWORD             ScrollLineFirst,ScrollLineLast,
  838.              ScrollLineCount;
  839. struct ScrollLineInfo    *ScrollLines;
  840.  
  841.     /* term review buffer. */
  842.  
  843. struct MsgPort        *ReviewPort;
  844. struct Window        *ReviewWindow;
  845.  
  846.     /* Background information. */
  847.  
  848. ULONG             BytesIn,
  849.              BytesOut;
  850. struct DateStamp     SessionStart;
  851. struct Window        *InfoWindow;
  852.  
  853.     /* Gadget support routines */
  854.  
  855. LONG             InterWidth,
  856.              InterHeight;
  857.  
  858.     /* Character translation. */
  859.  
  860. struct TranslationEntry    **SendTable,
  861.             **ReceiveTable;
  862.  
  863.     /* Window alignment information. */
  864.  
  865. struct WindowInfo WindowInfoTable[] =
  866. {
  867.     WINDOW_PACKET,    WC_ALIGNBELOW|WC_EXPANDWIDTH,    0,0,0,0,
  868.     WINDOW_STATUS,    WC_ALIGNRIGHT,            0,0,0,0,
  869.     WINDOW_FILE,    NULL,                0,0,0,0,
  870.     WINDOW_REVIEW,    WC_ALIGNTOP|WC_EXPANDWIDTH,    0,0,0,0,
  871.     WINDOW_FAST,    WC_ALIGNTOP|WC_ALIGNSIDE,    0,0,0,0,
  872.     WINDOW_FONT,    NULL,                0,0,0,0,
  873.     WINDOW_SCREEN,    NULL,                0,0,0,0,
  874.     WINDOW_PERF,    NULL,                0,0,0,0,
  875. };
  876.